var express = require('express');
var router = express.Router();

router.get('/', function(req, res, next) {
        console.log("接收客户端的请求==>>")
    res.json({"msg":"getstudent"})
});
//restful风格
/* router.get('/getstudentById/:stuid/:stuname', function(req, res, next) {
       //获得路径参数(restful)
    let {stuid,stuname} = req.params;
   /*  //获得查询字符串
    let {stuid,stuname} = req.query */
  
    //res.json({"msg":"get"+stuid+","+stuname})
//}); 


 router.get('/getstudentById', function(req, res, next) {
  
   //获得查询字符串
 let {stuid,stuname} = req.query 

 res.json({"msg":"get"+stuid+","+stuname})
}); 





router.post("/addstudent",function(req, res, next){

   let{stuname,stugender,stuage,stuclassid}=req.body
    console.log(stuname,stugender,stuage,stuclassid)

    res.json({"msg":"post"})
})

router.put("/updatestudent",function(req, res, next){
    res.json({"msg":"put"})

})

router.delete("/delstudent",function(req, res, next){
    res.json({"msg":"delete"})

})

module.exports = router;
